class Solution {
public:
    string modifyString(string s) {
        int len = s.size();
        if (len == 1)return "a";
        char left;
        char right = s[1];
        if (s[0] == '?') {
            for (char ch = 'a'; ch <= 'z'; ch++) {
                if (ch != right) {
                    s[0] = ch;
                    break;
                }
            }
        }

        for (int i = 1; i < s.size() - 1; i++) {
            left = s[i - 1];
            right = s[i + 1];
            if (s[i] == '?') {
                for (char ch = 'a'; ch <= 'z'; ch++) {
                    if (left != ch && right != ch) {
                        s[i] = ch;
                        break;
                    }
                }
            }
        }
        left = s[s.size() - 2];
        if (s[s.size() - 1] == '?') {
            for (char ch = 'a'; ch <= 'z'; ch++) {
                if (ch != left) {
                    s[s.size() - 1] = ch;
                    break;
                }
            }
        }

        return s;
    }
};